import Vue from 'vue'
import SelectType from '../common/table/components/dnycTable/SelectType.vue'

Vue.component('dync-control', {
  components: {
    SelectType
  },
  props: ['types', 'value', 'config'],
  render(h) {
    const self = this
    const { types = 'input', value, config = {} } = self
    let rendTag = types
    // 下拉框配置
    const { addtype = false, lists } = config
    if (types === 'number') {
      rendTag = `input-${types}`
    }
    return h(
      types !== 'select' ? `el-${rendTag}` : 'selectType',
      {
        props: { value, lists, addtype },
        on: {
          input(event) {
            self.$emit('input', event)
          }
        }
      }
    )
  }
})
